package com.kingyea.mobilepolice.apimanage.dictionary.service.impl;

import com.kingyea.mobilepolice.apimanage.client.UamServiceClient;
import com.kingyea.mobilepolice.apimanage.dictionary.service.DictionaryService;
import com.kingyea.mobilepolice.dictionary.bean.Dictionary;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

//import com.kingyea.mobilepolice.apimanage.dictionary.dao.DictionaryMapper;

/**
 * @author chenJW
 * @version v1.0.0
 * @description Dictionary 实现类
 * @date Created in 2018-02-27 10:47:04
 */
@Service
@Transactional
public class DictionaryServiceImpl implements DictionaryService {

    private static final Logger LOGGER = LoggerFactory.getLogger(DictionaryServiceImpl.class);

//    @Resource
//    private DictionaryMapper dictionaryMapper;

    @Autowired
    private UamServiceClient uamServiceClient;

//    /**
//     * 通过ID查找对象
//     *
//     * @param id
//     * @return
//     */
//    @Override
//    public Dictionary getById(Integer id) throws Exception {
//        return this.dictionaryMapper.getById(id);
//    }
//
//    /**
//     * 列表
//     *
//     * @param
//     * @return
//     */
//    @Override
//    public List<Dictionary> list(Dictionary dictionary) throws Exception {
//        List<Dictionary> list = dictionaryMapper.list(dictionary);
//        return list;
//    }
//
//    /**
//     * 删除
//     *
//     * @param id
//     * @return
//     */
//    @Send2Queue
//    @Override
//    public int deleteById(Integer id) throws Exception {
//        dictionaryMapper.deleteById(id);
//        return 1;
//    }
//
//    /**
//     * 保存
//     *
//     * @param dictionary
//     * @return
//     */
//    @Send2Queue
//    @Override
//    public Dictionary save(Dictionary dictionary) throws Exception {
//        dictionaryMapper.save(dictionary);
//        return dictionary;
//    }
//
//    /**
//     * 更新
//     *
//     * @param dictionary
//     * @return
//     */
//    @Send2Queue
//    @Override
//    public Dictionary update(Dictionary dictionary) throws Exception {
//        dictionaryMapper.update(dictionary);
//        return dictionary;
//    }

    @Override
    public List<Dictionary> getRootListByType(Map map) throws Exception {
        return uamServiceClient.searchDict(map).getData().getList();
//        if (!map.containsKey("type")) {
//            throw new BusinessException(StateCode.NO_ARGUMENT_ERROR);
//        }
//        return dictionaryMapper.getRootListByType(map);
    }

    @Override
    public List<Dictionary> getSubNodeListByPid(Map map) throws Exception {
        return uamServiceClient.searchDict(map).getData().getList();
//        if (!map.containsKey("pid")) {
//            throw new BusinessException(StateCode.NO_ARGUMENT_ERROR);
//        }
//        return dictionaryMapper.getSubNodeListByPid(map);
    }

}
